home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / ResExpress 1.0.1.sea / ResExpress 1.0.1 ƒ / ResX DevKit / Think Pascal / RXVW Shell w_Globals.p < prev    next >
Text File  |  1990-02-07  |  6KB  |  144 lines

  1. unit RXVWShell;
  2.  
  3. {RXVW Shell for ResX Views}
  4.  
  5. {To compile in Think Pascal:}
  6.  
  7. {   1) Set Project Type to 'Code Resource' }
  8. {   2) Set the File TYPE to 'RXXT' and File Creator to 'ResX'}
  9. {   3) Set the Resource TYPE to 'RXVW' }
  10. {   4) Set the Resource NAME to the resource type you are making a view for. }
  11. {        If you are making an ICON editor/viewer, set the name to 'ICON' }
  12. {   5) Add this file, DRVRRuntime.lib, and Interface.lib to the project }
  13. {   6) Compile/Build the code resource. }
  14. {   7) Install it in ResX via the 'Externals->Install' menu.  Or double-click on the external file in Finder. }
  15.  
  16.  
  17.  
  18.  
  19. {PRE-CONDITIONS}
  20. {    1) The handle to the current selected resource is passed directly into main.}
  21. {    2) The resource of that handle is NOT loaded.  It must be loaded if used.}
  22. {    3) The handle to the resource is NOT detached so all resource info can be found on the handle.}
  23. {    4) The Global Data is stored in the reference constant of the daWindow.  See example below on}
  24. {         how to access the globals.}
  25. {    5) It is mandatory to get the state of the handle (HGetState).  Restore the state when finished.}
  26.  
  27.  
  28. {POST-CONDITIONS}
  29. {    1) Do NOT release the resource or dispose the handle to the resource.  ResX will do it when}
  30. {        necessary.  ResX will check to see if the resource has been loaded by another environment.}
  31. {    2) Restore the state of the handle when finished (HSetState).}
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. interface
  39.     procedure main (ResHandle: Handle);  {Handle of the current selected resource}
  40.  
  41.  
  42. implementation
  43.     procedure main;
  44.         type
  45.  
  46.             SettingsHandle = ^SettingsPtr;                    {Contains Configuration setup, last and second}
  47.             SettingsPtr = ^SettingsRec;                        {to last files opened, and last move info}
  48.             SettingsRec = record
  49.                     unused1: Boolean;
  50.                     openStartup: Boolean;                            {Enable/Disable Open on Startup options}
  51.                     sortTList, sortRList: Boolean;                {Sort Type/Resource list}
  52.                     lastOneRefNum, lastTwoRefNum: integer;    {Last/Second to last volume reference number}
  53.                     lastOneName, lastTwoName: Str255;        {Last/Second to last file name}
  54.                     lastMoveType: ResType;                        {TYPE of the last resource copied}
  55.                     lastMoveID: integer;                            {Resource ID of the last resource copied}
  56.                     lastMoveSource, lastMoveDest: Str255;    {Source and Dest Files of the last resource copied}
  57.                     onStartup: integer;                                {Open on startup option: 1-Last File, 2-Last Two Files, 3-Open File Dialog}
  58.                     unused2: integer;
  59.                     dClick: integer;                                    {Current selected item of DoubleClick popup menu}
  60.                     helpFName: Str255;                            {Location of master Help file}
  61.                 end;
  62.  
  63.  
  64.  
  65.             GlobalsHndl = ^GlobalsPtr;                            {ResX Global Data - Some data can be programmably}
  66.             GlobalsPtr = ^GlobalsRec;                            {altered.  Alter with care!    * denotes DO NOT alter}
  67.             GlobalsRec = record
  68.                     theDevCtlEnt: DCtlPtr;                            {*Device Control Entry for DA*}
  69.                     rsrcBase: Integer;                                {*Resource Base*}
  70.                     daMenu: MenuHandle;                            {Main DA Menu}
  71.                     daFileID: Longint;                                {*File ID of DA*}
  72.  
  73.                     LeftFName, RightFName: Str255;                {Path and Name of Left & Right files currently opened}
  74.                     LeftVNum, RightVNum: integer;                {vRefNum of Left & Right files}
  75.                     LWasOpened, RWasOpened: Boolean;            {Left/Right file was opened priorly and shouldn't be closed}
  76.                     LcurType, RcurType: ResType;                {Current type displayed above resource lists}
  77.                     LTcurCell, RTcurCell: Cell;                    {Current selected cell in Left/Right TYPE list}
  78.                     LRcurCell, RRcurCell: Cell;                    {Current selected cell in Left/Right RESOURCE list}
  79.                     LfileID, RfileID: integer;                        {Left/Right File ID}
  80.                     prefsID: integer;                                {File ID of ResX Prefs in the System Folder}
  81.                     CompactLeft, CompactRight: Boolean;        {Left/Right resource map will be compacted when closed if TRUE}
  82.                     favMenu, extMenu, openMenu: MenuHandle;    {*Favorite File/Externals/Open File MenuHandles}
  83.                     Lopen, Ropen: Boolean;                            {True if Left/Right file is open and displayed in ResX}
  84.                     MFActive: Boolean;                            {*True if MultiFinder is running*}
  85.                     Settings: SettingsHandle;                        {Handle to Settings in Configuration setup}
  86.  
  87.                     LTypeList: ListHandle;                            {Handle to Left Type list}
  88.                     RTypeList: ListHandle;                            {Handle to Right Type list}
  89.                     LResList: ListHandle;                            {Handle to Left Resource list}
  90.                     RResList: ListHandle;                            {Handle to Right Resource list}
  91.  
  92.  
  93.                     Info: ControlHandle;                               {Get Info Button Control Handle}
  94.                     View: ControlHandle;                           {View Button Control Handle}
  95.                     OpenLeft: ControlHandle;                       {Open Left Button Control Handle}
  96.                     OpenRight: ControlHandle;                      {Open Right Button Control Handle}
  97.                     Remove: ControlHandle;                         {Remove Button Control Handle}
  98.                     Copy: ControlHandle;                           {Copy Button Control Handle}
  99.  
  100.  
  101.                 end;                                                {DO NOT alter globals denoted with *.  They can}
  102.                                                             {be accessed for reference only.}
  103.  
  104.  
  105.  
  106.         var
  107.             fileID, rsrID: integer;
  108.             rsrType: ResType;
  109.             rsrName, fName: Str255;
  110.             HState: SignedByte;
  111.             MF: Boolean;
  112.             Globals: GlobalsPtr;
  113.  
  114.     begin
  115.         Globals := GlobalsPtr(WindowPeek(FrontWindow)^.refCon);    {Required to access the Global Data}
  116.  
  117.  
  118.      {Sample of accessing the global data: }
  119.         fileID := Globals^.LFileID;                                        {Get the file id left file}
  120.         fName := Globals^.LeftFName;                                    {Get the file name of the left file}
  121.         MF := Globals^.MFActive;                                        {Is MultiFinder running?}
  122.  
  123.  
  124.         HState := HGetState(ResHandle);                                {This is mandatory!}
  125.  
  126.  
  127.         LoadResource(ResHandle);                                          {This is necessary if you plan to use it. }
  128.                                                                                        {ResX doesn't load it.}
  129.  
  130.  
  131.  
  132.      {.......}
  133.      {main code here}
  134.      {.......}
  135.  
  136.  
  137.  
  138.         HSetState(ResHandle, HState);                                      {This is mandatory!}
  139.  
  140.      {Do NOT release the resource or dispose the handle, ResX will do it if necessary. }
  141.      {This is critical in case the resource is being used by a currently running application. }
  142.  
  143.     end;
  144. end.